﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Expressing_Label
{
    public partial class checkpassword : Form
    {
        public checkpassword()
        {
            InitializeComponent();
            FormBorderStyle = FormBorderStyle.None;
        }

        private void passcheck_Click(object sender, EventArgs e)
        {
            CheckPwd_Mtd();
        }

        private void CheckPwd_Mtd()
        {
            if (PublicResources.g_checkcount <= 4 && inputpassword.Text.ToString() == PublicResources.g_password)
            {
                this.Hide();
                ConfigurationFrm cff = new ConfigurationFrm();
                cff.Owner = this;
                cff.Show();
            }
            else
            {
                if (PublicResources.g_checkcount >= 5)
                {
                    MessageBox.Show("对不起，您已达输入上限，请关闭程序后再次尝试");
                    inputpassword.Clear();
                }
                else
                {
                    MessageBox.Show("密码错误！");
                    PublicResources.g_checkcount++;
                    inputpassword.Clear();
                }

            }
        }

        private void passback_Click(object sender, EventArgs e)
        {
            Back_Mtd();
        }

        private void Back_Mtd()
        {
            this.Owner.Show();
            this.Close();
        }

        private void checkpassword_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == Convert.ToChar(Keys.Enter))
            {
                CheckPwd_Mtd();
            }
            else if (e.KeyChar == Convert.ToChar(Keys.Escape))
                Back_Mtd();
        }


    
    }
}
